<?php

namespace console\controllers;

use services\user\UserService;
use Yii;
use yii\console\Controller;


class UserController extends Controller
{
    /**
     * 月营销报表通知【每月1号上午9点】
     * 【* 9 1 * * php yii user/remind-month-bill】
     */
    public function actionRemindMonthBill()
    {
        try {
            $startTime = time();

            $service = new UserService();
            $service->getUserMonthBill();

            $endTime = time();
            $diffTime = $endTime - $startTime;

            echo "success" . PHP_EOL;
            echo "开始时间: {$startTime}" . PHP_EOL;
            echo "结束时间: {$endTime}" . PHP_EOL;
            echo "本次耗时: {$diffTime}" . PHP_EOL;
        } catch (\Exception $e) {
            echo 'error: ' . $e->getMessage() . PHP_EOL;
        }
    }
}
